home *** CD-ROM | disk | FTP | other *** search
- /**\
- |**| =====================================================================
- |**|
- |**| QDGX shell misc.c
- |**|
- |**| This file contains utility and menu handling routines for
- |**| the QuickDraw GX shell program.
- |**|
- |**| ©1992-1994 Apple Computer, Inc.
- |**| All rights reserved.
- |**|
- |**| =====================================================================
- \**/
-
-
- #include "QDGX shell.h"
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| DoMenuCommand()
- |**| This routine handles the dispatching of our menu requests.
- |**| ---------------------------------------------------------------------
- \**/
- void DoMenuCommand (long menuResult)
- {
- short menuID;
- short menuItem;
- Str255 daName;
- OSErr err;
- gxDialogResult result;
-
- menuID = menuResult >>16;
- menuItem = menuResult & 0x0000ffff;
-
- switch (menuID)
- {
- case mApple:
- switch (menuItem)
- {
- case iAbout: /* display About box */
- NoteAlert(rAboutBoxID,nil);
- break;
-
- default: /* handle DA selection */
- GetItem(GetMHandle(mApple), menuItem, daName);
- OpenDeskAcc(daName);
- break;
- }
- break;
-
-
- case mFile:
- switch (menuItem)
- {
- case iNew: /* create new window */
- err = DoCreateNew();
- break;
-
- case iOpen: /* open saved window */
- break;
-
- case iClose: /* close front window */
- DoDispose(FrontWindow());
- break;
-
- case iSave: /* save front window */
- break;
-
- case iPageSetup: /* perform page setup */
- HiliteMenu(0);
- err = DoFormat(FrontWindow(), &result);
- break;
-
- case iPrintOne: /* perform print-one */
- err = DoPrintOne(FrontWindow());
- break;
-
- case iPrint: /* perform print */
- HiliteMenu(0);
- err = DoPrinting(FrontWindow());
- break;
-
- case iQuit:
- gQuitting = true;
- break;
- }
- break;
-
-
- case mEdit:
- break;
- }
- HiliteMenu(0);
- }
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| GetDocShape()
- |**| This utility routine returns the page contents shape
- |**| attached to a window's document.
- |**| ---------------------------------------------------------------------
- \**/
- gxShape GetDocShape (WindowPtr wind)
- {
- TH_Doc doc;
- gxShape docPage = nil;
-
- if ( wind != NULL )
- {
- doc = (TH_Doc) GetWRefCon(wind);
- docPage = (*doc)->docPage;
- }
-
- return docPage;
- }
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| GetDocJob()
- |**| This utility routine returns the print job attached to a window's document.
- |**| ---------------------------------------------------------------------
- \**/
- gxJob GetDocJob (WindowPtr wind)
- {
- TH_Doc doc;
- gxJob docJob = nil;
-
- if ( wind != NULL )
- {
- doc = (TH_Doc) GetWRefCon(wind);
- docJob = (*doc)->docJob;
- }
-
- return docJob;
- }
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| MyStrLength()
- |**| This function takes the length of a C-style string quickly without
- |**| requiring an ANSI library to be linked in.
- |**| ---------------------------------------------------------------------
- \**/
- short MyStrLength (char *s)
- {
- short len;
-
- for (len = 0; *s++ != 0; len++) ;
- return len;
- }
-
-